package com.simple.javatraining.testing.testinside.questions;

import com.simple.javatraining.testing.testinside.answers.Answer;
import com.simple.javatraining.testing.testinside.answers.ProposedAnswer;

import java.util.ArrayList;
import java.util.List;

public abstract class Question {

private String textOfQuestion;
private List<ProposedAnswer> proposedAnswers = new ArrayList<ProposedAnswer>();
private int numberOfCorrectAnswers;

public Question(String textOfQuestion, List<ProposedAnswer> proposedAnswers) {
    this.textOfQuestion = textOfQuestion;
    this.proposedAnswers = proposedAnswers;
    numberOfCorrectAnswers = determineNumberOfCorrectAnswers();      
}

abstract public double checkUserAnswerForCorrect(Answer userAnswer);
abstract public void printHint();
abstract public void proposeVariantsOfAnswer();

private int determineNumberOfCorrectAnswers() {
	int numberOfCorrectAnswers = 0;
	for(ProposedAnswer currentAnswer:proposedAnswers) {
        if (currentAnswer.isCorrect()) {
            numberOfCorrectAnswers++;
        }
    }
	return numberOfCorrectAnswers;
}

public List<ProposedAnswer> getVariantsOfAnswer() {
    return this.proposedAnswers;
}

public int getNumberOfCorrectAnswers() {   
    return numberOfCorrectAnswers;
}

public String getTextOfQuestion() {
	return textOfQuestion;
}
}
